package com.briup.app02.web.controller;

import java.util.List;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.app02.bean.AccountApply;
import com.briup.app02.service.IAccountApplyService;
import com.briup.app02.utils.Message;
import com.briup.app02.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@Validated
@RequestMapping("/AccountApply")
@Api(description = "账户变动申请表（提现）")
public class AccountApplyController {

	
	@Autowired
	private IAccountApplyService IAS;

    @GetMapping("/findAll")
	@ApiOperation("查询所有信息")
	public List<AccountApply> findAll(){
		return IAS.findAll();	
	}
    

    @GetMapping("CheckNoPass")
    @ApiOperation(value="审核不通过")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "主键",paramType = "query",dataType="long",required = true),
        @ApiImplicitParam(name="reason",value = "原因",paramType = "query",required = true)
})
    public Message changeStatuestoNocheckPass(long id,String reason) {
    	IAS.changeStatus(id,"不通过",reason);
		return MessageUtil.success("更改成功！");
    }
    
    @GetMapping("CheckPass")
    @ApiOperation(value="审核通过")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "主键",paramType = "query",dataType="long",required = true),
        @ApiImplicitParam(name="reason",value = "原因",paramType = "query",required = true)
})
    public Message changeStatuestoCheckPass(long id,String reason) {
    	IAS.changeStatus(id,"通过",reason);
		return MessageUtil.success("更改成功！");
    }
    
    @ApiOperation(value = "撤销账户变动信息")
    @GetMapping("deleteById")
    @ApiImplicitParams({
    @ApiImplicitParam(name="id",value = "主键",paramType = "query", required=true),
    })
    public Message deleteById(@NonNull Long id){
    	IAS.deleteById(id);
        return MessageUtil.success("撤销成功！");
    }

    @ApiOperation(value = "提交账户变动申请信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "主键",paramType = "form",required = true),
            @ApiImplicitParam(name="money",value = "资金",paramType = "form"),
            @ApiImplicitParam(name="applyType",value = "申请类型（充值OR提现）",paramType = "form"),
            @ApiImplicitParam(name="applyTime",value = "申请时间",paramType = "form"),
            @ApiImplicitParam(name="status",value = " 状态",paramType = "form"),
            @ApiImplicitParam(name="userId",value = "userid",paramType = "form"),
            @ApiImplicitParam(name="reason",value = "原因",paramType = "form")
    })
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(AccountApply AA){
    	IAS.saveOrUpdate(AA);
        return MessageUtil.success("更新成功");
    }
	/*@Autowired
	private IaccounApplyService IAS;
	
	@GetMapping("/findAll")
	@ApiOperation("查询所有信息")
	public List<AccountApply> findAll(){
		return IAS.findAll();
		
	}
	@GetMapping("/findById")
	@ApiOperation("通过id查询信息")
	@ApiImplicitParam(name="id",value="栏目id",dataType="long",paramType="query",required=true)
	public AccountApply findById(long id) {
		return IAS.findById(id);
	}
	
	@GetMapping("/saveOrUpdate")
	@ApiOperation(value="添加或更新",notes="id为空是保存否则是更新")
	public String saveOrUpdate(AccountApply AA)
	{
		IAS.saveOrUpdate(AA);
		return "更新成 功！";
		
	}
	
	@DeleteMapping("/delete")
	@ApiOperation(value="根据id删除信息",notes="根据id删除信息")
	@ApiImplicitParam(name="id",value="栏目Id",dataType="Long",paramType="query",required=true)  //此注解是对参数的描述（参数为基本参数）
	public String delete(Long id) {
		IAS.delete(id);
		return "删除成功！";
	}*/
}
